package com.webapp.util;

import java.io.File;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.springframework.util.StringUtils;

import com.webapp.loader.XmlReportsLoader;

public class PathRule
{
  private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");

  public static String getHKSavePath(String foldername)
  {
    String savepath = XmlReportsLoader.getREPORT_ROOT();
    savepath = savepath + File.separator + foldername;
    return savepath;
  }
  public static String getHKSaveSheetPath(String foldername,String sheetName)
  {

	  String savepath = XmlReportsLoader.getREPORT_ROOT();
	  savepath = savepath + File.separator + foldername + File.separator + sheetName;
	  return savepath;
  }
  public static String getHKReportName(String prefix, Date date,String format)
  {
    String name = prefix;
    if(format.equals("xls")||format.equals("xlsx")){
    	if(System.getProperty("com.inforim.cognos.CognosClient").indexOf("C8")>0){
    		format="xls";
		}
    }
    name = name + "."+format;
    return name;
  }
  public static String getHKReportName(String prefix, Date date,String format, String paramString)
  {
	  String name = prefix;
	  if(format.equals("xls")||format.equals("xlsx")){
		  if(System.getProperty("com.inforim.cognos.CognosClient").indexOf("C8")>0){
			  format="xls";
		  }
	  }
	  if(StringUtils.isEmpty(paramString)) {
		  paramString = name;
	  }else {
		  paramString = ParamUtil.getSheelName(paramString);
	  }
	  name =  paramString+"."+format;
	  return name;
  }
  public static String getHKReportName(String prefix, Date date)
  {
    String name = prefix;

    name = name + ".xls";
    return name;
  }

  public static String getHKReportNamePDF(String prefix, Date date)
  {
    String name = prefix;

    name = name + ".pdf";
    return name;
  }

  public static void main(String[] args)
  {
    Calendar cal = Calendar.getInstance();
    System.out.println(getHKSavePath("Sales"));
    System.out.println(getHKReportName("Sales Report", cal.getTime()));
  }
}